package warrap;

import java.util.Scanner;

public class Demo01 {
    public static void main(String[] args) {
        // 1 long 如何转变 String 使用length（）
        long l=1234567890987654321l;
        String strl = String.valueOf(l);
        System.out.println(strl.length());
        //3
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入文件名字");
        String fileName = scanner.nextLine();
        checkFile(fileName);
        // 4
        String[] names={
                "张三","李四","王五","赵六","周七","王哲","白浩","贾蓉","慕容阿三","黄蓉"
        };
        for(int i=0;i<names.length;i++){
           char  lastChar = names[i].charAt(names[i].length()-1);
            for (int j = i+1; j < names.length ; j++) {
                boolean flag = names[j].endsWith(lastChar+"");
                if (flag)
                    System.out.println(names[i]+"和"+names[j]+"结尾相同");
            }
        }

        // 7
        String[][] books =new String[2][5];
        books[0][0]="java语言";
        books[0][1]="java web 语言";
        books[0][2]="c语言";
        books[0][3]="c++语言";
        books[0][4]="linux c语言";

        books[1][0]="论语";
        books[1][1]="资治通鉴";
        books[1][2]="四十二章经";
        books[1][3]="史记";
        books[1][4]="隋唐史";
        System.out.println("请输入书名");
        String bookName=scanner.nextLine();
        for(int i=0;i<books.length;i++){
            for(int j=0;j<books[i].length;j++){
                if(books[i][j].equals(bookName)){
                    System.out.println(bookName+"在"+(i+1)+"书柜"+(j+1)+"本");
                }
            }
        }


        // 8
        String[] webNames = {"mrsoft","mr","miss","Admin"};
        boolean flag=false;
        do {
            System.out.println("请输入注册的名字");
            String webName=scanner.nextLine().trim().toLowerCase();
            for(int i=0;i<webNames.length;i++){
                if (webName.equals(webNames[i].toLowerCase())){
                    System.out.println("用户名已使用");
                    flag=true;
                    break;
                }
            }
           if (!flag){
                System.out.println("注册成功！！！");
                return;
            }

        }while(flag);





    }

    private static void checkFile(String fileName) {
       String result = fileName.toUpperCase().endsWith(".MP4") ? "是" : "不是";
        System.out.println(result+"mp4格式");
      /* boolean f= fileName.toUpperCase().endsWith(".MP4");

       if(f) {
           System.out.println("是mp4格式");
       }else {
           System.out.println("不是mp4格式");
       }*/
    }
}
